<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    input {
        display: block;
        width: 300px;
        height: 30px;
        border: 1px solid;
        margin: auto;
    }

    p {
        width: 300px;
        height: 30px;
        border: 1px solid red;
        margin: auto;
    }
</style>

<body>
    <input type="text" name="" id="">
    <p></p>
    <script>
        var obj = Object.defineProperties({}, {
            text: {
                get: function () {
                    return this.val
                },
                set: function (a) {
                    p.innerHTML = a
                    this.val = a
                }
            }
        });
        // obj.text = 222
        console.log(obj)
        var input1 = document.querySelector("input")
        var p = document.querySelector("p")
        input1.onkeyup = function () {
            obj.text = input1.value
        }
    </script>

</body>

</html>